::
:: Copyright 2009 Lee Kemp
:: 
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
:: 
:: 	http://www.apache.org/licenses/LICENSE-2.0
:: 
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
:: 

@echo off
setlocal ENABLEDELAYEDEXPANSION

:: ###########################################################
:: Variables
:: Set JAVA_EXE and APPLICATION_HOME here
:: ###########################################################

set APPLICATION_HOME=.
set LIB_HOME="%APPLICATION_HOME%/lib"
set USER_LIB_HOME="%APPLICATION_HOME%/user/lib"
set JAVA_EXE=java
set JAVA_OPTS=

:: ###########################################################
:: Header
:: ###########################################################

echo ............................................................
echo Outburst framework core (test runner)
echo outburstframework.org
echo ............................................................

set _MAINCLASS=org.outburstframework.runner.OutburstTestRunner

goto start

:: ###########################################################
:: Functions 
:: ###########################################################

:start
	:: if ""%3"" == """" goto printHelp
	goto setClasspath

:startRunner
	set __COMMAND=%JAVA_EXE% -classpath "%_CLASSPATH%" %JAVA_OPTS% %_MAINCLASS%  %*
	echo ............................................................
	echo Starting runner
	echo %_MAINCLASS%
	echo %__COMMAND%
	echo ............................................................
	%__COMMAND%
	goto end

:setClasspath
	echo Setting the classpath using %LIB_HOME% and %USER_LIB_HOME%

	set _CLASSPATH=%CLASSPATH%
	FOR /R %LIB_HOME% %%G IN (*.*)DO set _CLASSPATH=!_CLASSPATH!;%%G 
	FOR /R %USER_LIB_HOME% %%G IN (*.*)DO  set _CLASSPATH=!_CLASSPATH!;%%G
	
	FOR /R %LIB_HOME% %%G IN (*.jar)DO echo %%G 
	FOR /R %USER_LIB_HOME% %%G IN (*.*)DO echo %%G
	goto startRunner

:printHelp
	echo ............................................................
	echo Usage
	echo outburst-runner.bat CLASS_NAME RUN_TIME RESULT_INTERVAL RUNS
	echo outburst-runner.bat com.kumkee.outburst.example.MapTest 3600000 10000 1000
	echo CLASS_NAME=The fully qualified name of the test class
	echo RUN_TIME=The amount of time to run the test in milliseconds
	echo RESULT_INTERVAL=Time between result logging in milliseconds
	echo RUNS=The number of times to run the tests
	echo ............................................................
	goto end

:end

